#ifndef STATUSBARINFO_H
#define STATUSBARINFO_H

#include <QString>

/**
 * StatusBarInfo - 状态栏信息值对象
 *
 * Martin Fowler重构：Extract Value Object
 * 将散布的状态栏参数封装成不可变值对象
 */
class StatusBarInfo
{
public:
    StatusBarInfo() = default;

    StatusBarInfo(int currentIndex, int totalFiles, const QString& fileName)
        : m_currentIndex(currentIndex)
        , m_totalFiles(totalFiles)
        , m_fileName(fileName)
    {
    }

    // Getters
    int currentIndex() const { return m_currentIndex; }
    int totalFiles() const { return m_totalFiles; }
    QString fileName() const { return m_fileName; }

    // 显示索引（从1开始）
    int displayIndex() const { return m_currentIndex + 1; }

    // 验证
    bool isValid() const {
        return m_totalFiles > 0 && m_currentIndex >= 0 && m_currentIndex < m_totalFiles;
    }

    // 格式化显示文本
    QString formatText() const {
        if (!isValid()) {
            return m_totalFiles == 0 ? "无文件" : "无选择";
        }

        QString shortName = m_fileName;
        if (shortName.length() > 20) {
            shortName = shortName.left(17) + "...";
        }

        return QString("文件 %1/%2: %3").arg(displayIndex()).arg(m_totalFiles).arg(shortName);
    }

private:
    int m_currentIndex = -1;
    int m_totalFiles = 0;
    QString m_fileName;
};

#endif // STATUSBARINFO_H